<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="author" content="zhangjiarui">
  <meta name="keywords" content="kindness>
  <meta name="description" content="this web is a place to show your kindness">
  <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://cdn.bootcss.com/bootstrap-table/1.11.1/bootstrap-table.min.css" rel="stylesheet">
  <title>好人之家——张嘉睿</title>
 <body class="body">
  <table class="toptable" background="background2.jpg">
		<tr>
		    <td align="center"class="topword"><h3>伟大&nbsp;只有&nbsp;<h3><h1>风流&nbsp;<h1><h3>尤其&nbsp;<h3><h2>技术部&nbsp;<h2><h3>最牛&nbsp;<h3></td>
		</tr>
  </table>
 </body>

<style>
.whole{
	border: 100px;
	width: 900px;
	margin-left: 350px;
	background-size=100%;
}
.button {
    margin-left: 30px;
}
.maintable {
    width: 400px;
	height: 500px;
	border:10px solid #7FFF00;
}		
.maintable2 {
	border:5px solid #D19275;
}		
.word {
    font-style:italic;
	font-weight:bold;
	font-size:20px;
	margin-right:30px;
}
.topword {
    font-style:italic;
	font-weight:bold;
	font-size:20px;
	color:red;
}
.toptable{
	height: 300px;
	width: 1000px;
	margin-left: 300px;
	background-size=100%;
	opacity: 0.5;
}
.body{
	background:url(background.jpg) no-repeat;
	background-size:100%;
}
input[type="submit"]{
     width:285px;
	 height:55px;
}	
</style>

</head>

<body>

<table class="whole">
	<tr> 
		<td class="maintable"><img src="good.jpg" width="400" height="500" /></td>
		<td rowspan="2">
				<table class="maintable2">
                <tr>
					<td><h3><strong>注册界面</strong><h3></td>
                </tr>
                <tr>
					<td class="word">用户名</td>
					<td>
						<input id="username" type="text" class="text" placeholder="请输入用户名">
					</td>
                </tr>
                
				<tr>
					<td class="word">邮箱</td>
					<td>
						<input id="useremail" type="text" class="text" placeholder="请输入邮箱">
					</td>
                </tr>
				
                <tr>
					<td class="word">密码</td>
					<td>
						<input id="userpassword" type="password" class="text" placeholder="请输入密码">
					</td>
                </tr> 
                
                <tr>
					<td class="word">确认密码</td>
					<td>
						<input id="userpassword2" type="password" class="text" placeholder="请确认密码">
					</td>
                </tr>
               
                <tr>
					<td>
							<input id="register" class="button" type="submit" value="注册" onclick="test()">
							<input id="login" class="button" type="submit" value="返回登陆" onclick="go_back()">
					</td>
                </tr>
                </table>
		</td>
	</tr>
</table>

</body>

<script>
	function test() 
	{
        if (!window.localStorage) 
		{
            alert("localstorage好像不能用啊......");
            return;
        } 
		else 
		{
            var newusername = document.getElementById('username');
            var username = newusername.value;

            checkname(username); 
            checkemail();
            registering(username);
        }
            
    }

    function checkname(username) 
	{
        if (username == "") 
		{
            alert("您还没名儿呢！！！");
            return;
        }

    }

    function checkemail() 
	{
        var newuseremail = document.getElementById('useremail');
        var useremail = newuseremail.value;
        var a = useremail.indexOf("@",0);
        var b = useremail.indexOf(".",0);
        if (useremail == "") 
		{
            alert("您怎么把邮箱忘啦");
            return;
        }
        if (a > b) 
		{
            alert("您内个.跑@前面啦");
            return;
        }
        if (useremail.indexOf("@",0) == -1) 
		{
            alert("哎呦，少了个@");
            return;
        }
        if (useremail.indexOf(".",0) == -1) 
		{
            alert("哎呦，少了个.");
            return;
        }
    }

    function registering(username) 
	{
        var newuserpassword = document.getElementById('userpassword');
        var userpassword = newuserpassword.value;
        var newuserpassword2 = document.getElementById('userpassword2');
        var userpassword2 = newuserpassword2.value;
        if (userpassword.length == 0) 
		{
            alert("没密码可够吓人的");
            return;
        }
        if (userpassword2.length == 0) 
		{
            alert("不确定密码您再给忘喽");
            return;
        }     
        if (userpassword != userpassword2)
		{
            alert("这会儿功夫就给忘了密码了");
            return;
        }
		
        var storage = window.localStorage;
        var usernameStorage =  storage.username;
        if (username == usernameStorage) 
		{
            alert("真不巧，重名了");
            return;
        }    

        storage["username"] = username;
        storage["password"] = userpassword;

        var newuseremail = document.getElementById('useremail');
        var useremail = newuseremail.value;
        storage["email"] = useremail;

        var date = new Date();
        var currentTime = date.toLocaleString();
        storage["registerTime"] = currentTime;

        alert("得嘞您，欢迎您加入好人之家");
    }

    function go_back() 
	{
	    alert("这回返回登录界面啦");
        window.open("https://zhangdahaihaha.gitee.io/denglu2");
    }
        
    
</script>

</html>





















